/**
 * Created by zxr on 2016/5/15.
 */
var mysql = require('mysql');
var  conn = null;
exports.connect = function(){
    conn = mysql.createConnection({
        host:'localhost',
        'user':'root',
        'password':'',
        'database':'expert',
         port:'3306'
    });
    conn.connect(function(error){
        if(error){
            console.log(error);
        } else {
            console.log('tid' + conn.threadId);
        }
    });
}
exports.query = function(sql,format, func){
    conn.query(sql,format, func);
}
exports.close = function(){
    conn.end();
}
//=============/自定义函数
exports.getConnection = function(){
    return conn;
}
//转义
exports.escapestring = function(){
    conn.escape();
}